1. Field of the Invention
The present invention generally relates to computer systems, specifically to a method of maintaining cache coherency in a multiprocessor computer system, and more particularly to an improved cache coherency protocol which allows the point of coherency (or coherency control) to dynamically float so as to more efficiently handle cache operations in systems with complicated interconnection topologies.
2. Description of Related Art
The basic structure of a conventional multiprocessor computer system 10 is shown in FIG. 1. Computer system 10 has several processing units, two of which 12a and 12b are depicted, which are connected to various peripheral devices, including input/output (I/O) devices 14 (such as a display monitor, keyboard, graphical pointer (mouse), and a permanent storage device or hard disk), memory device 16 (such as random access memory or RAM) that is used by the processing units to carry out program instructions, and firmware 18 whose primary purpose is to seek out and load an operating system from one of the peripherals (usually the permanent memory device) whenever the computer is first turned on. Processing units 12a and 12b communicate with the peripheral devices by various means, including a generalized interconnect or bus 20, or direct memory access channels (not shown). Computer system 10 may have many additional components which are not shown, such as serial, parallel, and universal system bus (USB) ports for connection to, e.g., modems, printers or scanners. There are other components that might be used in conjunction with those shown in the block diagram of FIG. 1; for example, a display adapter might be used to control a video display monitor, a memory controller can be used to access memory 16, etc. The computer can also have more than two processing units.
In a symmetric multiprocessor (SMP) computer, all of the processing units are generally identical, that is, they all use a common set or subset of instructions and protocols to operate, and generally have the same architecture. A typical architecture is shown in FIG. 1. A processing unit includes a processor core 22 having a plurality of registers and execution units, which carry out program instructions in order to operate the computer. An exemplary processing unit includes the PowerPC(trademark) processor marketed by International Business Machines Corp. The processing unit can also have one or more caches, such as an instruction cache 24 and a data cache 26, which are implemented using high speed memory devices. Caches are commonly used to temporarily store values that might be repeatedly accessed by a processor, in order to speed up processing by avoiding the additional latency of loading the values from memory 16. These caches are referred to as xe2x80x9con-boardxe2x80x9d when they are integrally packaged with the processor core on a single integrated chip 28. Each cache is associated with a cache controller (not shown) that manages the transfer of data and instructions between the processor core and the cache memory.
A processing unit can include additional caches, such as cache 30, which is referred to as a level 2 (L2) cache since it supports the on-board (level 1) caches 24 and 26. In other words, cache 30 acts as an intermediary between memory 16 and the on-board caches, and can store a much larger amount of information (instructions and data) than the on-board caches can, but at a longer access penalty. For example, cache 30 may be a chip having a storage capacity of 512 kilobytes, while the processor may be an IBM PowerPC(trademark) 604-series processor having on-board caches with 64 kilobytes of total storage. Cache 30 is connected to bus 20, and all loading of information from memory 16 into processor core 22 must come through cache 30. Although FIG. 1 depicts only a two-level cache hierarchy, multi-level cache hierarchies can be provided where there are many levels (L3, L4, etc.) of serially connected caches.
In a multi-level cache, if a copy of a value is in every level of the cache, the cache hierarchy is referred to as being xe2x80x9cinclusive.xe2x80x9d It is not necessary, however, to keep a copy of each value in the lower levels, and an inclusivity bit field may be added to the caches to indicate whether or not the cache is inclusive. For example, a three-level cache structure might provide an L3 cache which was not inclusive, such that a value residing in the L2 cache might not be present in the L3 cache. In this example, if an L2 cache issues a read command for a value that is not present in any of the caches of that processing unit, it can be passed to that L2 cache without (necessarily) loading it into the L3 cache.
In an SMP computer, it is important to provide a coherent memory system, that is, to cause write operations to each individual memory location to be serialized in some order for all processors. By way of example, assume a location in memory is modified by a sequence of write operations to take on the values: 1, 2, 3, 4. In a cache coherent system, all processors will observe the writes to a given location to take place in the order shown. However, it is possible for a processing element to miss a write to the memory location. A given processing element reading the memory location could see the sequence 1, 3, 4, missing the update to the value 2. A system that implements these properties is said to be xe2x80x9ccoherentxe2x80x9d. Nearly all coherency protocols operate only to the granularity of the size of a cache block. That is to say, the coherency protocol controls the movement of and write permissions for operand data or instructions on a cache block basis, and not separately for each individual memory location.
There are a number of protocols and techniques for achieving cache coherence that are known to those skilled in the art. All of these mechanisms for maintaining coherency require that the protocols allow only one processor to have a xe2x80x9cpermissionxe2x80x9d that allows a write operation to a given memory location (cache block) at any given point in time. As a consequence of this requirement, whenever a processing element attempts to write to a memory location, it must first inform all other processing elements of its desire to write the location and receive permission from all other processing elements to carry out the write.
To implement cache coherency in a system, the processors communicate over a common generalized interconnect (i.e., bus 20). The processors pass messages over the interconnect indicating their desire to read from or write to memory locations. When an operation is placed on the interconnect, all of the other processors xe2x80x9csnoopxe2x80x9d(monitor) this operation and decide if the state of their caches can allow the requested operation to proceed and, if so, under what conditions. There are several bus transactions that require snooping and follow-up action to honor the bus transactions and maintain memory coherency. The snooping operation is triggered by the receipt of a qualified snoop request, generated by the assertion of certain bus signals. Instruction processing is interrupted only when a snoop hit occurs and the snoop state machine determines that an additional cache snoop is required to resolve the coherency of the offended sector.
This communication is necessary because, in systems with caches, the most recent valid copy of a given block of memory may have moved from the system memory 16 to one or more of the caches in the system (as mentioned above). If a processor (say 12a) attempts to access a memory location not present within its cache hierarchy, the correct version of the block, which contains the actual (current) value for the memory location, may either be in the system memory 16 or in one of more of the caches in another processing unit, e.g. processing unit 12b. If the correct version is in one or more of the other caches in the system, it is necessary to obtain the correct value from the cache(s) in the system instead of system memory.
For example, consider a processor, say 12a, attempting to read a location in memory. It first polls its own L1 cache (24 or 26). If the block is not present in the L1 cache, the request is forwarded to the L2 cache (30). If the block is not present in the L2 cache, the request is forwarded on to lower cache levels, e.g., the L3 cache. If the block is not present in the lower level caches, the request is then presented on the generalized interconnect (20) to be serviced. Once an operation has been placed on the generalized interconnect, all other processing units snoop the operation and determine if the block is present in their caches. If a given processing unit has the block requested by processing unit in its L1 cache, and the value in that block is modified, and any lower level caches also have copies of the block, then their copies are stale, since the copy in the processor""s cache is modified. Therefore, when the lowest level cache (e.g., L3) of the processing unit snoops the read operation, it will determine that the block requested is present and modified in a higher level cache. When this occurs with an in-line cache structure, the L3 cache places a message on the generalized interconnect informing the processing unit that it must xe2x80x9cretryxe2x80x9d it""s operation again at a later time, because the actual value of the memory location is in the L1 cache at the top of the memory hierarchy and must be retrieved to make it available to service the read request of the initiating processing
Once the request from an initiating processing unit has been retried, the L3 cache begins a process to retrieve the modified value from the L1 cache and make it available at the L3 cache, main memory or both, depending on the exact details of the implementation. To retrieve the block from the higher level caches, the L3 cache sends messages through the inter-cache connections to the higher level caches, requesting that the block be retrieved. These messages propagate up the processing unit hierarchy until they reach the L1 cache and cause the block to be moved down the hierarchy to the lowest level (L3 or main memory) to be able to service the request from the initiating processing unit.
The initiating processing unit eventually re-presents the read request on the generalized interconnect. At this point, however, the modified value has been retrieved from the L1 cache of a processing unit and placed into system memory, and the read request from the initiating processor will be satisfied. The scenario just described is commonly referred to as a xe2x80x9csnoop pushxe2x80x9d. A read request is snooped on the generalized interconnect which causes the processing unit to xe2x80x9cpushxe2x80x9d the block to the bottom of the hierarchy to satisfy the read request made by the initiating processing unit.
Thus, when a processor wishes to read or write a block, it must communicate that desire with the other processing units in the system in order to maintain cache coherence. To achieve this, the cache coherence protocol associates with each block in each level of the cache hierarchy, a status indicator indicating the current xe2x80x9cstatexe2x80x9d of the block. The state information is used to allow certain optimizations in the coherency protocol that reduce message traffic on the generalized interconnect and the inter-cache connections. As one example of this mechanism, when a processing unit executes a read it receives a message indicating whether or not the read must be retried (i.e., reissued later). If the read operation is not retried, the message usually also includes information allowing the processing unit to determine if any other processing unit also has a still active copy of the block (this is accomplished by having the other lowest level caches give a xe2x80x9csharedxe2x80x9d or xe2x80x9cnot sharedxe2x80x9d indication for any read they do not retry). Therefore, a processing unit can determine whether any other processor in the system has a copy of the block. If no other processing unit has an active copy of the block, the reading processing unit marks the state of the block as xe2x80x9cexclusivexe2x80x9d. If a block is marked exclusive it is permissible to allow the processing unit to later write to the block without first communicating with other processing units in the system because no other processing unit has a copy of the block. Therefore, it is possible for a processor to read or write a location without first communicating this intention onto the interconnection, but only where the coherency protocol has ensured that no other processor has an interest in the block.
The foregoing cache coherency technique is implemented in a specific protocol referred to as xe2x80x9cMESI,xe2x80x9d and illustrated in FIG. 2. In this protocol, a cache block can be in one of four states, xe2x80x9cMxe2x80x9d (Modified), xe2x80x9cExe2x80x9d (Exclusive), xe2x80x9cSxe2x80x9d (Shared) or xe2x80x9cIxe2x80x9d (Invalid). Under the MESI protocol, each cache entry (e.g., a 32-byte sector) has two additional bits which indicate the state of the entry, out of the four possible states. Depending upon the initial state of the entry and the type of access sought by the requesting processor, the state may be changed, and a particular state is set for the entry in the requesting processor""s cache. For example, when a sector is in the Modified state, the addressed sector is valid only in the cache having the modified sector, and the modified value has not been written back to system memory. When a sector is Exclusive, it is present only in the noted sector, and is consistent with system memory. If a sector is Shared, it is valid in that cache and in at least one other cache, all of the shared sectors being consistent with system memory. Finally, when a sector is Invalid, it indicates that the addressed sector is not resident in the cache. As seen in FIG. 2, if a sector is in any of the Modified, Shared or Invalid states, it can move between the states depending upon the particular bus transaction. While a sector in an Exclusive state can move to any other state, a sector can only become Exclusive if it is first Invalid.
A further improvement in accessing cache blocks can be achieved using the cache coherency protocol. This improvement referred to as xe2x80x9cintervention,xe2x80x9d allows a cache having control over a memory block to provide the data in that block directly to another cache requesting the value (for a read-type operation), in other words, bypassing the need to write the data to system memory and then have the requesting processor read it back again from memory. Intervention can generally be performed only by a cache having the value in a block whose state is Modified or Exclusive. In both of these states, there is only one cache block that has a valid copy of the value, so it is a simple matter to source (write) the value over the bus 20 without the necessity of first writing it to system memory. The intervention procedure thus speeds up processing by avoiding the longer process of writing to and reading from system memory (which actually involves three bus operations and two memory operations). This procedure not only results in better latency, but also increased bus bandwidth.
There are many variations of the MESI protocol. The tagged (xe2x80x9cTxe2x80x9d) state is used to identify a cache block which is inconsistent with system memory (i.e., modified) and is further responsible for writing the correct (current) value to memory upon deallocation (or to pass on the tag to another cache block during intervention). The T state can be used to share a modified value, by marking one of the sharing blocks as (temporarily) responsible for maintaining a valid copy of the value. The recently read (xe2x80x9cRxe2x80x9d) state can be used to allow intervention when the value is unmodified but shared among many caches, so as to conveniently mark a single one of the sharing caches as being responsible for intervention. The hover (xe2x80x9cHxe2x80x9d) state allows a cache line to maintain an address in the directory even though the corresponding value in the cache entry array is an invalid copy, so that it can snoop the correct value for its processing unit if the value happens to be broadcast as part of an intervention between the caches of two other processing units.
In simpler systems, such as that shown in FIG. 1, a system controller 32 acts as a central receiver to coordinate coherency responses (controller 32 is often integrated into main memory 16). When a device issues a read, write or deallocation request, and various other devices in the system snoop and respond to the request (as discussed above), their responses are generally collected by controller 32 which then formulates a combined response to return to the requesting device (master). The combined response is based on known response priority logic.
Controller 32 is also typically responsible for protecting the target cache line until non-retry responses are received from all of the snoopers. For example, a bus master (processing unit or I/O device) may issue a read-with-intent-to-modify (RWITM) request, and one of the snoopers may provide a response indicating that its cache currently holds the requested value and can intervene it, but other snoopers may issue retry responses. In such a case, controller 32 ensures that no other master accesses the requested memory block until completion of the first operation.
As the number of processing units in multiprocessor systems has increased, the interconnection topologies for the processing units, cache and system memory have become quite complicated, and can lead to inefficiencies in the handling of coherency operations. Multiprocessor systems with large numbers of processors (e.g., 32) are often grouped into processing clusters, with two or more processor sharing lower level (L2) caches, and the processing clusters being coupled to one another using multiple buses, switches and cross-bars. In such systems, all snooping devices may not receive a master""s request at the same time due to different delays through the interconnection topology. The intricate nature of these connections makes it more difficult to collect all responses in a timely manner, and form a proper combined response, particularly when a device in one processing cluster contains a value that is requested by a device in a different processing cluster. The difficulty is compounded if two masters simultaneously issue conflicting access requests to different sectors of the same cache line. The result is an overall reduction in system performance.
Providing a central point of coherency is additionally much more problematic for systems with distributed memory, such as non-uniform memory access (NUMA) systems wherein RAM is divided among two or more memory arrays allocated to respective processing units. A NUMA memory architecture is common with the aforementioned systems having a large number of processors grouped into clusters. With such systems, a single controller cannot be located in such a manner as to be able to efficiently monitor all of the snoop responses and control all of the memory devices.
In light of the foregoing, it would be desirable to provide a method of serializing cache transactions which did not require a central point of coherency, such as that afforded by a system controller. It would be further advantageous if the method could easily protect a requested cache line until completion of an initial cache operation without adversely affecting system performance.
It is therefore one object of the present invention to provide an improved method of maintaining cache coherency in a multiprocessor system.
It is another object of the present invention to provide such a method which does not require a central point of coherency, i.e., a single system controller which formulates a combined response.
It is yet another object of the present invention to provide an improved method of handling cache operations in a multiprocessor system having a plurality of processor clusters and a distributed system memory.
The foregoing objects are achieved in a method of maintaining cache coherency in a multiprocessor computer system, comprising the steps of designating a single cache as a highest point of coherency (HPC) for a particular memory block (wherein the cache contains a valid value corresponding to the memory block), issuing a request for the value from a master device of the computer system, and sending a snoop response from the cache indicating that it is currently the HPC for the memory block and can service the request. The designation may be performed in response to a particular coherency state assigned to the cache line which uniquely identifies the cache line with respect to the memory block or, alternatively, based on the setting of a coherency token bit for the cache line. In an illustrative embodiment, the processing units are grouped into clusters which are coupled using cross-bar switches, and the memory is distributed using memory arrays associated with respective clusters. One of the memory arrays, which contains the memory block, is further designated as a lowest point of coherency (LPC) for the memory block. This memory array can first protect the memory block from any conflicting operation, and the cache thereafter will protect the memory block until completion of the requested transaction. An acknowledgement snoop response is sent from the LPC memory array and the HPC cache, and a combined response is returned to the master device which gives priority to the snoop response from the HPC cache over the acknowledgement snoop response from the memory array, i.e., the HPC controls the coherency response. The combined response may include an indication of a coherency state to be assigned to a cache line of the master device upon receiving the value.
The above as well as additional objectives, features, and advantages of the present invention will become apparent in the following detailed written description.